package com.xxxx.server.controller;


import com.xxxx.server.pojo.Position;
import com.xxxx.server.pojo.RespBean;
import com.xxxx.server.service.IPositionService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhoubin
 * @since 2020-08-17
 */
@RestController
@RequestMapping("/system/basic")
public class PositionController {

    @Autowired
    private IPositionService positionService;

    /**
     * 查询所有职位信息
     * @return
     */
    @ApiOperation(value = "获取所有的职位信息")
    @GetMapping("/pos")
    public List<Position> getAllPositions (){
        return positionService.getAllPositions();
    }
    /**
     * 添加职位
     * @param position
     * @return
     */
    @ApiOperation(value = "添加职位")
    @PostMapping("/pos")
    public RespBean addPosition (@RequestBody Position position){
        System.out.println(position);

     return  positionService.addPosition(position);


        /**
         * 更新职位信息
         * @param name
         * @return
         */
    }
    @ApiOperation(value = "更新职位信息")
    @PutMapping("/pos")

    public RespBean updatePosition (@RequestBody Position position){
        System.out.println(position);
        return positionService.updatePosition(position);

    }
    /**
     *删除职位
     * @return
     */
    @ApiOperation(value ="删除职位")
    @DeleteMapping("/pos/{id}")
    public RespBean deletePosition (@PathVariable Integer id) {
        System.out.println(id);
      return  positionService.deletePosition(id);

    }


    /**
     * 多项删除
     */
    @ApiOperation(value = "多项删除")
    @DeleteMapping("/pos/")
    public RespBean deletePositions (String  ids ){
        System.out.println(ids);

        return positionService.deletePositions(ids);
    }


}
